<?php

/**
 * MVM_MALL 网上商店系统 搜索关键字管理
 * ============================================================================
 * 版权所有 (C) 2007-2010 www.mvmmall.com，并保留所有权利。
 * 网站地址: http://www.mvmmall.com
 * ----------------------------------------------------------------------------
 * 这是一个免费开源的软件；这意味着您可以在不用于商业目的的前提下对程序代码
 * 进行修改、使用和再发布。
 * ============================================================================
 * $Author:  www.mvmmall.com  $
 * $Date: 2008-11-15 $
 * $Id: search_key.inc.php  www.mvmmall.com$
 * ---------------------------------------------
*/

if(!defined('MVMMALL') || !defined('IN_ADMINCP')) exit('Access Denied');
if($action=='list'){
    require_once MVMMALL_ROOT.'./include/pager.class.php';
    $rs = $db->fetch_row($db->query("SELECT COUNT(*) AS total_num,search_word FROM `{$tablepre}search_table`  GROUP BY search_word ORDER BY total_num DESC"));
    $total_count = $rs[0];
    $page        = $page ? (int)$page:1;
    $list_num    = 10;
    $rowset      = new Pager($total_count,$list_num,$page);
    $from_record = $rowset->_offset();
    $result      = $db->query("SELECT COUNT(*) AS total_num,search_word,search_id,uid FROM `{$tablepre}search_table`  GROUP BY search_word ORDER BY total_num DESC LIMIT $from_record, $list_num");
    while ($rt   = $db->fetch_array($result)) {
        $sch_rt[]               = $rt;
    }
    $page_list = $rowset->link("admincp.php?module=$module&action=$action&page=");
    require_once template('search_key');
    footer();
} elseif ($action=='del'){
	if (is_array($tables_id)) {
		foreach ($tables_id as $val){
			$val = dhtmlchars($val);
			$db->query("DELETE FROM `{$tablepre}search_table` WHERE search_word='$val';");
		}
		hot_search(4,'update');
		admin_msg('success',dreferer());
	}else {
		admin_msg('pass_worng');
	}
}  else {
    admin_msg('pass_worng');
}